export default function ajax(url = '', params = {}, type = 'GET') {
  // 定义promise对象
  let promise = new Promise((resolve, reject) => {
    wx.request({
      url: url,
      data: params,
      method: type,
      header: {
        "content-type": "application/json"
      },
      success: res => {
        if(res.data.data == 'login_fail'){
          wx.removeStorageSync('loginToken');

          setTimeout(() =>{
            wx.redirectTo({
              url:'/pages/equipment/management'
            })
          },2100)

        }
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
  return promise
}
